<!DOCTYPE HTML>
<html>
<head>
    {include file="layout:_meta" /}
    <title>职位模块</title>
</head>
<body>



    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div id="table" class="page-container">
    <div class="text-c">
        <span class="select-box" style="width:150px">
			<select class="select" name="brandclass" size="1"  v-model="search.status" >
                			<option value=""><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">申请状态</font></font></option>
				<option value="1" selected="">
                    <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">申请中</font></font></option>
				<option value="2"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">已完成</font></font></option>
				<option value="3"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">已已拒绝</font></font></option>
			</select>
			</span>
        <input type="text" class="input-text"  v-model="search.searchval" style="width:250px" placeholder="姓名/电话">
        <button type="submit" v-on:click="btnSearch()" class="btn btn-success" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            参与的职位
        </span>
        <span class="r">共有数据：<strong>{{count}}</strong> 条</span></div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr class="text-c">
            <th width="25"><input type="checkbox" @click="selectAll"></th>


            <th width="150">报名人姓名</th>
            <th width="150">报名人电话</th>
            <th width="150">报名人性别</th>
            <th width="150">创建时间</th>
            <th width="150"> 申请职位 </th>
            <th width="150">
                申请状态
            </th>
<!--            <th width="100">操作</th>-->
        </tr>
        </thead>
        <tbody>
        <tr class="text-c" v-for="(item,index)  in lists">
            <td><input type="checkbox" :value="index" v-model="selectArr"></td>
            <td> {{item.realname}}   </td>
            <td>{{item.mobile}}</td>
            <td>
                <span v-if="item.sex==1">男</span>
                <span v-else-if="item.sex==2">女</span>
            </td>
            <td> <span v-text="gettime(item.ctime)"></span></td>
            <td> <span v-text="getcompanytext(item)" >  </span> </td>
            <td>
                <!-- 1申请中  2已完成  3已拒绝 -->
                <span  v-if="item.status==1" > 申请中 </span>
                <span  v-if="item.status==2" > 已完成 </span>
                <span  v-if="item.status==3" > 已拒绝 </span>

            </td>

<!--        <td class="f-14 product-brand-manage">-->

  <!--          <input title="查看职位"
                   v-bind:data-id="item.id" v-on:click="adminInfo($event,item,index)"
                   class="btn btn-warning size-MINI radius" type="button" value="查看参与的职位">-->
<!--            <a style="text-decoration:none" v-bind:data-id="item.id" v-on:click="adminInfo($event,item,index)"  href="javascript:;" title="查看参与的职位">-->
<!--                <i class="Hui-iconfont"> &#xe623; </i> </a>-->
<!--        </td>-->
        </tr>
        </tbody>
    </table>
    <!--vueJS分页---start-->
    <div class="pagination">
        <ul>
            <li v-if="current>1"><a v-on:click="current--,pageClick()">上一页</a></li>
            <li v-if="current==1"><a class="banclick">上一页</a></li>
            <li v-for="index in indexs"  v-bind:class="{ 'active': current == index}">
                <a v-on:click="btnClick(index)">{{ index }}</a>
            </li>
            <li v-if="current!=total"><a v-on:click="current++,pageClick()">下一页</a></li>
            <li v-if="current == total"><a class="banclick">下一页</a></li>
            <li><a>共<i>{{total}}</i>页</a></li>
        </ul>
    </div>
    <!--vueJS分页---end-->
</div>
<!--_footer 作为公共模版分离出去-->
{include file="layout:_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->

<!--<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>-->
<script type="text/javascript">
    var models = {
        selectArr:[],
        count:0,
        lists: [],//表格数据
        total:1, //总页数
        current:1,  //当前页码
        search:{
            status:'',
            hunter_id:"{$hunter_id}",
        }   //搜索框
    };

    var app_model = new Vue({
        el: "#table",
        data: models,
        mounted: function () {
        },
        methods: {
            //添加按钮
            adminAdd:function () {
                var url = "{:url('bounty/set')}";
                admin_add('添加',url,'800','500');
            },
            //编辑
            adminEdit: function (event) {
                var _this = $(event.currentTarget);
                var id = _this.attr('data-id');
                var url = "{:url('bounty/set')}" + "?id=" + id +"&pageno="+this.current;
                admin_edit('编辑', url,'800','500');
            },
            //详参与的职位
            adminInfo:function(event,item,index){
                console.log(item);
                layer.open({
                    type: 2,
                    area: ["80%", '80%'],
                    fix: false, //不固定
                    maxmin: true,
                    shade:0.4,
                    title: '查看发布的职位',
                    content:"/admin/bounty/activejob?user_id="+item.user_id,
                });
            },
            //删除按钮
            btnDel: function (event, index) {
                var _this = $(event.currentTarget);
                var id = _this.attr('data-id');
                admin_del("{:url('bounty/remove')}", _this, id, index);
            },
            //全选
            selectAll(event) {
                var _this = this;
                console.log(event.currentTarget.checked)
                if (!event.currentTarget.checked) {
                    _this.selectArr = [];
                } else { //实现全选
                    _this.selectArr = [];
                    _this.lists.forEach(function(item, i) {
                        _this.selectArr.push(i);
                    });
                }
            },
            //部分删除
            datadel:function (ele,delid,index) {
                var len = this.lists.length;
                var ids = [];
                var arridx = [];
                if (delid) {
                    ids.push(delid);
                    arridx.push(index);
                }
                // for (var i = 0; i < len; i++) {
                //     if (this.selectArr[i]>=0) {
                //         let idx = this.selectArr[i];
                //         arridx.push(idx);
                //         ids.push(this.lists[idx].id);
                //     }
                // }

                admin_alldel("{:url('bounty/remove')}", this, JSON.stringify(ids), arridx);
                this.selectArr = [];
            },
            //上一页,下一页翻页
            pageClick: function(){
                initTable("{:url('bounty/activejob')}",this.current,this.search);
            },

            //点击页码
            btnClick: function(data){
                if(data != this.current){
                    this.current = data;
                    initTable("{:url('bounty/activejob')}",this.current,this.search);
                }
            },
            //搜索框搜索
            btnSearch:function () {

                initTable("{:url('bounty/activejob')}",this.current,this.search);
            },
            // 身份
           Status: function($status){
                $content = '未知 ';
                switch ($status) {
                    case  0:
                        $content = '审核中'; // 0 1正常
                        break;
                    case 1 :
                        $content = '正常';
                        break;
                }
                return $content;
            },
            // 展示公司信息
            getcompanytext:function(item){
                var html = '';
                if (item.position) {
                    html += "标题:"+item.position.title+" \n\r";
                    html += "公司:"+item.position.company_name+" \n\r";
                    html += "地区:"+item.position.region_name+" \n\r";
                }
                return html;
            },
            //用户详情
            showinfo:function(event,$userid){
                console.log($userid);
            },
            gettime:function (nS) {
                    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
            },
            // 通过 审核
            userpass:function (event,id,index) {
                console.log(index);
                layer.confirm('确认要审核通过吗？',function(){
                    util.post("{:url('bounty/pass')}",{id:id},function (data) {
                        if(data.status==true){
                          app_model.lists[index].status = 1;
                        }
                        layer.msg(data.message,{icon:1,time:1000});
                    });
                });
            },

        },

        //分页
        computed: {
            indexs: function () {
                var left = 1;
                var right = this.total;
                var ar = [];
                if (this.total >= 5) {
                    if (this.current > 3 && this.current < this.total - 2) {
                        left = this.current - 2;
                        right =left + 4;
                    } else {
                        if (this.current <= 3) {
                            left = 1;
                            right = 5;
                        } else {
                            right = this.total;
                            left = this.total - 4;
                        }
                    }
                }
                while (left <= right) {
                    ar.push(left);
                    left++;
                }
                return ar
            }
        },
        mounted:{
            // 渲染完成后的操作；

        }
    });
    //初始化数据表格
    initTable("{:url('bounty/activejob')}"+"?hunter_id={$hunter_id}", {$pageno});
</script>
</body>
</html>